package jface.util;

import jface.JFaceTreeImageExample;
import jface.data.Person;
import jface.data.Person.Gender;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

public class PersonIconLabelProvider extends LabelProvider  {
		
	public String getText(Object element) {
		Person person = (Person) element;
		return person.getFirstName()+" "+person.getLastName()+" ("+person.getAge()+")";
	}
		
	public Image getImage(Object element) {
		Person person = (Person) element;
		if(person.getEmployees().isEmpty()){
			if(person.getGender() == Gender.female){
				return JFaceTreeImageExample.imageRegistry.get("minion_f");
			}else{
				return JFaceTreeImageExample.imageRegistry.get("minion_w");				
			}
		}else{
			return JFaceTreeImageExample.imageRegistry.get("manager");
		}
	}

}
